﻿using System;
using System.Reflection;
using System.Configuration;
namespace Maticsoft.DALFactory
{
	/// <summary>
    /// Abstract Factory pattern to create the DAL。
    /// 如果在这里创建对象报错，请检查web.config里是否修改了<add key="DAL" value="Maticsoft.SQLServerDAL" />。
	/// </summary>
	public sealed class DataAccess 
	{
        private static readonly string AssemblyPath = ConfigurationManager.AppSettings["DAL"];        
		public DataAccess()
		{ }


        #region 泛型生成
        ///// <summary>
        ///// 创建数据层接口。
        ///// </summary>
        //public static t Create(string ClassName)
        //{

        //    string ClassNamespace = AssemblyPath +"."+ ClassName;
        //    object objType = CreateObject(AssemblyPath, ClassNamespace);
        //    return (t)objType;
        //}
        #endregion

        #region CreateSysManage
        public static Maticsoft.IDAL.ISysManage CreateSysManage()
		{
			//方式1			
			//return (Maticsoft.IDAL.ISysManage)Assembly.Load(AssemblyPath).CreateInstance(AssemblyPath+".SysManage");

			//方式2 
            return new Maticsoft.SQLServerDAL.SysManage();		
		}
		#endregion
             
        
   
		/// <summary>
		/// 创建Accounts数据层接口。
		/// </summary>
		public static Maticsoft.IDAL.IAccounts CreateAccounts()
		{

			return new Maticsoft.SQLServerDAL.Accounts();
		}


		/// <summary>
		/// 创建Books数据层接口。
		/// </summary>
		public static Maticsoft.IDAL.IBooks CreateBooks()
		{
			return new Maticsoft.SQLServerDAL.Books();
		}


		/// <summary>
		/// 创建bookTypes数据层接口。
		/// </summary>
		public static Maticsoft.IDAL.IbookTypes CreatebookTypes()
		{
			return new Maticsoft.SQLServerDAL.bookTypes();
		}


		/// <summary>
		/// 创建Chooses数据层接口。
		/// </summary>
		public static Maticsoft.IDAL.IChooses CreateChooses()
		{
			return new Maticsoft.SQLServerDAL.Chooses();
		}


		/// <summary>
		/// 创建Detaileds数据层接口。
		/// </summary>
		public static Maticsoft.IDAL.IDetaileds CreateDetaileds()
		{
            return new Maticsoft.SQLServerDAL.Detaileds();
		}


		/// <summary>
		/// 创建Employees数据层接口。
		/// </summary>
		public static Maticsoft.IDAL.IEmployees CreateEmployees()
		{
            return new Maticsoft.SQLServerDAL.Employees();
		}


		/// <summary>
		/// 创建Foods数据层接口。
		/// </summary>
		public static Maticsoft.IDAL.IFoods CreateFoods()
		{
            return new Maticsoft.SQLServerDAL.Foods();
		}


		/// <summary>
		/// 创建FoodTypes数据层接口。
		/// </summary>
		public static Maticsoft.IDAL.IFoodTypes CreateFoodTypes()
		{
            return new Maticsoft.SQLServerDAL.FoodTypes();
		}


		/// <summary>
		/// 创建Launchs数据层接口。
		/// </summary>
		public static Maticsoft.IDAL.ILaunchs CreateLaunchs()
		{
            return new Maticsoft.SQLServerDAL.Launchs();
		}


		/// <summary>
		/// 创建Sources数据层接口。
		/// </summary>
		public static Maticsoft.IDAL.ISources CreateSources()
		{
            return new Maticsoft.SQLServerDAL.Sources();
		}


		/// <summary>
		/// 创建sysdiagrams数据层接口。1
		/// </summary>
		public static Maticsoft.IDAL.Isysdiagrams Createsysdiagrams()
		{
            return new Maticsoft.SQLServerDAL.sysdiagrams();
		}


		/// <summary>
		/// 创建Users数据层接口。1
		/// </summary>
		public static Maticsoft.IDAL.IUsers CreateUsers()
		{
            return new Maticsoft.SQLServerDAL.Users();
		}


		/// <summary>
		/// 创建UserTypes数据层接口。1
		/// </summary>
		public static Maticsoft.IDAL.IUserTypes CreateUserTypes()
		{
            return new Maticsoft.SQLServerDAL.UserTypes();
		}

}
}